<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			.ok{
				color: green;
			}
			.error{
				color: red;
			}
		</style>
		<script type="text/javascript">
			function checkName(){
				var name = document.getElementById("name").value;
				var reg1 = /^\w{5,10}$/;
				var result = name.match(reg1);
				var span1 = document.getElementById("showMsg");
				if(result == null){
					span1.className = "error";
				}else{
					span1.className = "ok";
				}
			}
			function checkPassword(){
				var passwd = document.getElementById("password").value;
				var reg2 = /^\w{10,20}$/;
				var result = passwd.match(reg2);
				var span2 = document.getElementById("showMsg2");
				if(result == null){
					span2.className = "error";
				}else{
					span2.className = "ok";
				}
			}
		</script>
	</head>
	<body>
		账号:<input id="name" type="text" onblur="checkName()"/>
		<span id="showMsg">5-10位字母、数字、下划线</span>
		<br />
		密码:<input id="password" type="text" onblur="checkPassword()"/>
		<span id="showMsg2">10-20位字母、数字、下划线</span>
		<br />
		<input id="password" type="button" value="登录"/>
	</body>
</html>
